package com.songshuai.webapi.baseapi.controller;

import com.songshuai.webapi.baseapi.dto.feign.response.MasterSourceItemDto;
import com.songshuai.webapi.baseapi.pojo.QueryResponse;
import com.songshuai.webapi.baseapi.service.SchoolMasterSourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("线下校长端渠道")
@Slf4j
@RestController
@RequestMapping("/api/mastersource/")
public class SchoolMasterSourceController {


    @Autowired
    private SchoolMasterSourceService sourceService;



    @ApiOperation(value = "获取所有来源")
    @GetMapping("querySourceList")
    public QueryResponse<List<MasterSourceItemDto>> queryMasterSourceList(){
        List<MasterSourceItemDto> masterSourceItemList = sourceService.getAllSources();
        return QueryResponse.setResData(masterSourceItemList);
    }

    @ApiOperation(value = "根据Id获取来源")
    @GetMapping("querySourceById")
    public QueryResponse<MasterSourceItemDto> querySourceById(@RequestParam Integer id){
        MasterSourceItemDto masterSourceItemList = sourceService.getSourceById(id);
        return QueryResponse.setResData(masterSourceItemList);
    }

    @ApiOperation(value = "根据id获取来源")
    @PostMapping("querySourceByIds")
    public QueryResponse<List<MasterSourceItemDto>> querySourceByIds(@RequestBody List<Integer>ids){
        List<MasterSourceItemDto> masterSourceItemList = sourceService.getSourceByIds(ids);
        return QueryResponse.setResData(masterSourceItemList);
    }

}
